package com.fit.service;

import java.io.Serializable;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Component;

import com.fit.interfaces.CarI;
@Component
public class CarsBean implements CarsI {

	private Map<String, CarI> cars;

	public CarsBean(HashMap<String, CarI> cars) {
		super();
		this.cars = cars;
	}

	public CarsBean() {
		cars = new HashMap<String, CarI>();
	}
	
	
	
	public CarI save(CarI car){
		return cars.put(car.getModelName(), car);
	}
	
	/* (non-Javadoc)
	 * @see com.fit.service.CarsI#retrive()
	 */
	public Collection<CarI> retrive(){
		return cars.values();
	}
	/* (non-Javadoc)
	 * @see com.fit.service.CarsI#retriveSingleCar(java.io.Serializable)
	 */
	public CarI retriveSingleCar(Serializable id){
		return cars.get(id);
	}

	
	public CarI editSingleCar(CarI car) {
		
		return cars.put(car.getModelName(), car);
	}
//	public CarI deleteSingleCar(Serializable id){
//		return cars.remove(id);
//		
//	}
	
}
